package com.config;

import com.rabbitmq.client.AMQP;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 配置消息队列的：
 * 交换机
 * 队列
 *
 */

@Configuration
public class MQConfig {

    @Bean
    public FanoutExchange fanoutExchange(){
        return new FanoutExchange("fanoutExchange_2020_2");


    }


    /**
     * 队列
     * @return
     */
    @Bean("queue_2020_2_1")
    public Queue queue1(){
        return new Queue("queue_2020_2_1");
    }

    /**
     * 队列
     * @return
     */
    @Bean("queue_2020_2_2")
    public Queue queue2(){
        return new Queue("queue_2020_2_2");
    }


    @Bean("fanoutExchange_2020_2_---------------------queue_2020_2_1")
    public Binding binding1(){
        return BindingBuilder.bind(queue1()).to(fanoutExchange());
    }


    @Bean("fanoutExchange_2020_2_---------------------queue_2020_2_2")
    public Binding binding2(){
        return BindingBuilder.bind(queue2()).to(fanoutExchange());
    }

}
